<html>
<head>
<h1>View Students</h1>
</head>
<body>
<?php
	require "config.php"; // NOTE:It's a best practice to keep your private information in different file which has access to limited people
	$con = mysql_connect("localhost",$db_user ,$db_pass);
	// if an error was encountered, the script exits with an error message
	if (!$con){
		die('Could not connect: ' . mysql_error());
    }
	mysql_select_db($db_name, $con); //connecting with the database
	$sql_fetch = "Select * from student"; // SQL query for selecting all the records from the 'student' table
	$result = mysql_query($sql_fetch); //records returned from database are stored in $result variable	
?>
<table border='1'>
<tr> 
<td><b>ID</b></td>
<td><b>Name</b></td>
</tr>
<? while($row = mysql_fetch_array($result)){
	echo "<tr>";
	echo "<td>" . $row['ID'] . "</td>";
	echo "<td>" . $row['Name'] . "</td>";
	echo "<td><form method='POST' name='updateForm' action='editstudent.php'>
    <input type='hidden' name= 'id' value=".$row['ID'].">
    <input type='submit' name='Edit' value='Edit'> 
    </form></td>";
	echo "</tr>";
}
	mysql_close($con);?>
</table>
<a href="student.php">Home</a>
</body>
</html>
